from bs4 import BeautifulSoup
import re
import urllib.request, urllib.error

def getPage(url, fileName):
    head = {
        "User-Agent": "android/okhttp"
    }

    request = urllib.request.Request(url, headers=head)
    html = ""
    try:
        response = urllib.request.urlopen(request)
        html = response.read().decode("utf-8")
    except:
        
        hnn
    fp = open('./pageSave/' + fileName +'.html', 'w',encoding='utf-8')
    print('我也不知道我在干什么了')
    
    fp.write(html)
    fp.close()

def main():
    # url = "https://movie.douban.com/top250?start="
    url = 'http://www.nipic.com/design/acg/renwu/index.html'
    fileName = 'nipic_pictture'
    getPage(url, fileName)

if __name__ == "__main__":
    main()